import { UserInfo } from '@/data/auth-info'
import { ENV } from '@server/env'

export const adminUserInfo: UserInfo = {
  id: 'admin',
  name: '管理员',
  auth: {
    canViewAbout: true,
    canDeleteRelease: true,
    canUpdateRelease: true,
    canPublishRelease: true,
    canUploadPackage: true,
    canDownloadPackage: true,
    canGetPackageList: true,
    canGetReleaseList: true,
    canViewClientInfo: true,
    canSaveClientInfo: true,
    canManageGrayGroups: true,
  },
}

export const uploadUserInfo: UserInfo = {
  id: 'upload',
  name: '上传者',
  auth: {
    canViewAbout: false,
    canDeleteRelease: false,
    canUpdateRelease: false,
    canPublishRelease: false,
    canUploadPackage: true,
    canDownloadPackage: false,
    canGetPackageList: false,
    canGetReleaseList: false,
    canViewClientInfo: false,
    canSaveClientInfo: false,
    canManageGrayGroups: false,
  },
}

export const customUserInfo: UserInfo = {
  id: 'custom',
  name: '游客',
  auth: {
    canViewAbout: false,
    canDeleteRelease: false,
    canUpdateRelease: false,
    canPublishRelease: false,

    canUploadPackage: ENV.UPLOAD_ANYONE,
    canDownloadPackage: true,
    canGetPackageList: true,
    canGetReleaseList: true,

    canViewClientInfo: false,
    canSaveClientInfo: false,
    canManageGrayGroups: false,
  },
}

export function getUserInfo(id: string) {
  if (id === 'admin') {
    return adminUserInfo
  }
  if (id === 'upload') {
    return uploadUserInfo
  }
  return customUserInfo
}
